class GalleryController < ApplicationController
  caches_page   :about, :unknown_request
  # Displays the home page of the application.
  # The home page shows the most recently uploaded picture.
  def index
    @gallery = Gallery.instance
    @currentPhoto = @gallery.getCurrentPhoto
    @currentPhotoDetails = @gallery.flickr.photos.getInfo(@currentPhoto[0])
    @context = @gallery.flickr.photos.getContext(@currentPhoto[0])
    @tags = @gallery.flickr.tags.getListPhoto(@currentPhoto[0])
  end
  # Gets the photo on the basis of the photo id passed.
  def photos
    if params[:id]
      @gallery = Gallery.instance
      @currentPhotoDetails = @gallery.flickr.photos.getInfo(params[:id])
      @context = @gallery.flickr.photos.getContext(params[:id])
      @tags = @gallery.flickr.tags.getListPhoto(params[:id])
      render(:template => "gallery/index")
    else
      redirect_to(:action => 'index')
    end
  end
  # Shows the about page
  def about
    @realName = LIGHTBOX_CONFIG[:real_name]
  end
  # Handles malformed requests in the application
  def unknown_request
    render(:template => "gallery/404")
  end
end
